<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
    <title>组件的状态</title>
</head>
<body>
<div id="app"></div>

<!--script-->
<script src="lib/react/react.js"></script>
<script src="lib/react/JSXTransformer.js"></script>
<script type="text/jsx">
    var MessageBox = React.createClass({
        getInitialState: function () {
            return {
                isVisible:true,
                count:"你好世界！！！（来自state哦）"
            }
        },
        render: function () {
            var styleObj = {
                display:this.state.isVisible? 'block' : 'none'
            }
            return (
                <div>
                    <h1 style={styleObj}>{this.state.count}</h1>
                    <SubMessage/>
                </div>
            );
        }
    });

    var SubMessage = React.createClass({
        render: function () {
            return (
                <div>
                    <h3>写代码很有意思</h3>
                    <Footer/>
                </div>
            )
        }
    });

    var Footer = React.createClass({
        render: function () {
            return (
                <div>
                    <small>因为我在用代码创造</small>
                </div>
            )
        }
    })


   var messageBox =  React.render(<MessageBox/>,
        document.getElementById("app"),
        function () {
            console.log("渲染完成了")
        });
</script>
</body>
</html>
